Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't fetch the current item for a null test session #2469

Conversation

hectoras
Copy link
Contributor

@hectoras hectoras commented May 16, 2024

Associated Jira issue: INF-268

Fixes a race condition that happens when the same test taker launches two executions concurrently, causing the logic to pause the timers for the first one that got processed to try to fetch a test session that may not have been persisted yet.

Changelog:

  • Don't call getCurrentAssessmentItemRef() on null when an execution does not have a test session assigned (yet)
    • If there's no test session, there's no current item nor item duration to adjust
  • Don't try to suspend() the same delivery execution twice

This fixes a customer-reported error, and has already been validated on their side. The error was:

/var/www/html/taoQtiTest/model/Service/ConcurringSessionService.php@146:
   Uncaught Error: Call to a member function getCurrentAssessmentItemRef() on null in
     /var/www/html/taoQtiTest/model/Service/ConcurringSessionService.php:146

Stack trace:
#0 /var/www/html/ltiDeliveryProvider/controller/DeliveryTool.php(145):
    oat\taoQtiTest\model\Service\ConcurringSessionService->adjustTimers(
        Object(oat\taoDelivery\model\execution\DeliveryExecution)
    )
#1 [internal function]: oat\ltiDeliveryProvider\controller\DeliveryTool->run() 
...

@hectoras hectoras force-pushed the fix/INF-268-prevent-adjusttimers-error-on-execution-with-no-session branch from ab125c2 to 9c69e78 Compare May 16, 2024 14:44
Copy link

github-actions bot commented May 16, 2024

Front-end summary Node 18

💯 Total ✅ Passed ⏭️ Skipped ❌ Failed
708 708 0 0

@hectoras hectoras marked this pull request as ready for review May 16, 2024 15:13
Copy link

Version

Target Version 48.5.1
Last version 48.5.0

There are 0 BREAKING CHANGE, 0 feature, 1 fix

@@ -67,15 +69,19 @@ public function __construct(
DeliveryExecutionService $deliveryExecutionService,
FeatureFlagCheckerInterface $featureFlagChecker,
StateServiceInterface $stateService,
TestSessionService $testSessionService,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Can you please make sure there is no other DI Service provider instantiating this class apart of TestQtiServiceProvider? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just checked and it is only used in the TestQtiServiceProvider from this extension, and all instantiations at runtime are done though the PSR container.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor

@gabrielfs7 gabrielfs7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Code looks good, but I cannot check it.

  • New code is covered by tests (if applicable)
  • Tests are running successfully (old and new ones) on my local machine (if applicable)
  • New code is respecting code style rules
  • New code is respecting best practices
  • New code is not subject to concurrency issues (if applicable)
  • Feature is working correctly on my local machine (if applicable)
  • Acceptance criteria are respected
  • Pull request title and description are meaningful

@hectoras
Copy link
Contributor Author

These changes have two approvals and the fix was validated by QA, therefore I'm merging this PR.

@hectoras hectoras merged commit c22ae07 into develop May 20, 2024
5 checks passed
@hectoras hectoras deleted the fix/INF-268-prevent-adjusttimers-error-on-execution-with-no-session branch May 20, 2024 08:52
@hectoras
Copy link
Contributor Author

Released as v48.5.2.

pnal pushed a commit that referenced this pull request Jun 6, 2024
* fix: Don't fetch the current item for a null test session

* chore: Use DI to fetch services from ConcurringSessionService

* chore: Fix tests

(cherry picked from commit c22ae07)
pnal added a commit that referenced this pull request Jun 6, 2024
…ntAssessmentAtemRef-on-null

fix: Don't fetch the current item for a null test session (#2469)
wazelin pushed a commit that referenced this pull request Jun 10, 2024
* fix: Don't fetch the current item for a null test session

* chore: Use DI to fetch services from ConcurringSessionService

* chore: Fix tests

(cherry picked from commit c22ae07)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants